package org.spolo.android.app.topic;

import org.spolo.android.support.nodetree.Stage;

/**
 * topic管理类，用于管理各topic之间的切换
 * 
 * @author Administrator
 * 
 */
public class AppTopicManager {
	/**
	 * 设备展示--外部展示
	 */
	public static final int SHOW360 = 0;

	protected BaseTopic topic[] = new BaseTopic[15];
	protected int currentTopic = -1;
	public Stage root = Stage.getInstance();

	private static AppTopicManager app = null;

	private AppTopicManager() {
	}

	static public AppTopicManager instance() {
		if (app == null) {
			app = new AppTopicManager();
		}
		return app;
	}

	private void ActiveTopic(int topic) {
		// 拿到当前的topic,去做没完完成的事,return true 之后再跳转
		if (currentTopic == -1) {
		} else if (currentTopic >= 0) {
			this.topic[currentTopic].Deactive();
		}
		this.topic[topic].Active();
		currentTopic = topic;
	}

	public void topicChanged(int topic) {
		if (topic != currentTopic) {
			ActiveTopic(topic);
		}

	}

	public BaseTopic getTopic(int topic) {
		return this.topic[topic];
	}

	/**
	 * 获取当前的topic
	 * 
	 * @return
	 */
	public BaseTopic getCurrentTopic() {
		return this.topic[currentTopic];
	}

}
